<!doctype html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>test2</title>
	
	<!-- Latest compiled and minified CSS -->
	<link rel="stylesheet" href="css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="css/default.css">
	<!-- Optional theme -->
	<link rel="stylesheet" href="css/bootstrap-theme.min.css">
	<link rel="stylesheet" href="css/font-awesome.min.css">
	<!-- Avivo CSS --> 
    <link rel="stylesheet" href="assets/css/avivo.css" />
    
	<!--[if IE]>
		<script src="http://libs.useso.com/js/html5shiv/3.7/html5shiv.min.js"></script>
	<![endif]-->
</head>
<body>
	<header class="htmleaf-header">
		<div class="htmleaf-demo center">
		  <a href="index.html">DEMO1</a>
		  <a href="index2.html" class="current">DEMO2</a>
		</div>
	</header>

	<div class="login">
		<img src="assets/img/profile.jpg" alt="..." class="img-circle photo-user">
		<div class="login-form">
    		<form action="desktop.html">
    			<div class="input-group">
					<input class="form-control" placeholder="Username" type="text">
					<span class="input-group-addon"><i class="fa fa-user"></i></span>
				</div>
    			<div class="input-group">
					<input class="form-control" placeholder="Password" type="text">
					<span class="input-group-addon"><i class="fa fa-key"></i></span>
				</div>
    		</form>
		</div>
	</div>
	<!-- Latest compiled and minified JavaScript -->
    <script src="http://libs.useso.com/js/jquery/2.1.0/jquery.min.js"></script>
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
    <script src="assets/js/avivo.js"></script>
<script>
	//window.Core = window.$ = {};

	var Core = {};
	var _cache = {};

	Core.config = {
		shortcutTop:20,		//快捷方式top初始位置
		shortcutLeft:20,		//快捷方式left初始位置
		createIndexid:1,		//z-index初始值
		windowMinWidth:150,		//窗口最小宽度
		windowMinHeight:56,		//窗口最小高度
		windowMaxHeight:$(window).height()-30
	};

	Core.loadTpl = '<div class="loading"></div>';
	//var data = [[{}, {}, {}], [{}]];
	//桌面右键菜单
	// Core.menu={
	//     bodymenudata:
	//     [
	//     [{
	//         text: "排列图标",
	//         data: [[{
	//             text: "名称",
	//             func: function() {
	//                 ZENG.msgbox.show("按名称排列！", 1, 2000);
	//             }
	//         }, {
	//             text: "大小",
	//             func: function() {
	//                 ZENG.msgbox.show("按大小排列！", 1, 2000);
	//             }
	//         }, {
	//             text: "类型",
	//             func: function() {
	//                 ZENG.msgbox.show("按类型排列！", 1, 2000);
	//             }
	//         }]]
	//     },
	//     {
	//         text: "刷新",
	//         func: function() {
	//             //ZENG.msgbox.show($(this).parent().attr('id'), 1, 2000);
	//             $('body').reload();
	//         }
	//     }, {
	//         text: "新建",
	//         data: [[{
	//             text: "文本文件",
	//             func: function() {
	//                 ZENG.msgbox.show("文本文件！", 1, 2000);
	//             }
	//         }, {
	//             text: "Execl",
	//             func: function() {
	//                 ZENG.msgbox.show("Execl！", 1, 2000);
	//             }
	//         }]]
	//     },{
	//         text:"显示桌面",
	//         func:function(){
	//             Core.showDesktop();
	//         }
	//     }
	//     ],
	//     [{
	//         text: "属性(选择背景)",
	//         data: [[{
	//             text: "背景1",
	//             func: function() {
	//                 $(this).attr("style",'background:url(images/background.jpg) repeat right bottom transparent;');
	//             }
	//         }, {
	//             text: "背景2",
	//             func: function() {
	//                 $(this).attr("style",'background:url(images/background2.jpg) repeat right bottom transparent;');
	//             }
	//         }]]
	//     }]
	//     ],
	//     icosmenudata : [[{
	//         text:"工具栏"
	//     }, {
	//         text:"任务管理器"
	//     }, {
	//         text:"显示桌面"
	//     }], [{
	//         text:"属性"
	//     }]]
	// };
	Core.init = function(userPermission){
		$(document.body).bind('click',function(){
			//隐藏所有右键列表
			$(".popup-menu").hide();
		});
		var _top = Core.config.shortcutTop;
		var _left = Core.config.shortcutLeft;
		var windowHeight = $("#desk ul").height();
		var ul = $("#desk").find('ul');
		//屏蔽桌面右键事件
		// $("#desk").bind('contextmenu',function(){
		//     $(".popup-menu").hide();
		//     $("#desk").smartMenu(Core.menu.bodymenudata, {
		//         name: "body"
		//     });
		//     $("#task-bar").smartMenu(Core.menu.icosmenudata, {
		//         name: "task_bar"
		//     });
		//     return false;
		// });
		/**/
		for(var sc in shortcut){
			var iconId = shortcut[sc][0];
			var permission = [];
			if(userPermission && typeof userPermission[iconId] != 'undefined'){
				permission = userPermission[iconId];
			} else {
				permission = [0,0];
			}

			if(!(shortcut[sc][6] || permission[0]))
				continue;
			_cache.shortcutTemp = {
				"top":_top,
				"left":_left,
				"title":shortcut[sc][1],
				"shortcut":shortcut[sc][0],
				"imgsrc":shortcut[sc][2],
				"isWrite":permission[1]
			};
			$(ul).append(FormatModel(shortcutTemp,_cache.shortcutTemp));
			//每循环一个图标后，给top的偏移量加90px
			_top += 100;
			//当下一个图标的top偏移量大于窗口高度时，top归零，left偏移量加90px
			if(_top+Core.config.shortcutTop+57 > windowHeight){
				_top += 10;
				_left = Core.config.shortcutLeft;
			}
		}

		$('.exit').click(function(){
			require(['wx.pop','wx.ajax'],function(wx){
				wx.confirm('是否要退出？',{fn:function(){
					wx.sendData('/login/logout',function(){location.reload();});
				}});
			});
		});

		$(window).bind('resize',function(){
			// if($(window).width()<800 || $(window).height()<400){
			//     ZENG.msgbox.show("浏览器当前窗口过小，可能会影响正常操作！", 1, 2000);
			// }
			//由于图标不会太多，所以resize里的方法是对样式直接修改，当然也可以重建li
			_top = Core.config.shortcutTop;
			_left = Core.config.shortcutLeft;
			windowHeight = $("#desk ul").height();
			//循环ul，操作每一个li
			$(ul).find("li").each(function(){
				$(this).css({
					"left":_left,
					"top":_top
				});
				_top += 90;
				if(_top+Core.config.shortcutTop+80 > windowHeight){
					_top = Core.config.shortcutTop;
					_left += 90;
				}
			});
			//智能修改每个窗口的定位
			$("#desk div.window-container").each(function(){
				currentW = $(window).width() - $(this).width();
				currentH = $(window).height() - $(this).height();
				_l = $(this).data("info").left/$(this).data("info").emptyW*currentW >= currentW ? currentW : $(this).data("info").left/$(this).data("info").emptyW*currentW;
				_l = _l <= 0 ? 0 : _l;
				_t = $(this).data("info").top/$(this).data("info").emptyH*currentH >= currentH ? currentH : $(this).data("info").top/$(this).data("info").emptyH*currentH;
				_t = _t <= 0 ? 0 : _t;
				$(this).css({
					"left":_l+"px",
					"top":_t+"px"
				});
			});
		}).bind('load',function(){
			$('.bgloader').fadeOut('slow');
		});

		$(window).resize();
		//绑定快捷方式点击事件
		// ul.find('li').live('click',function(){
		//     Core.create($(this));
		// });
		// ul.delegate('li','click',function(){
		//     Core.create($(this));
		// })
		ul.find('li').dblclick(function(){
			Core.create($(this));
		});
		//绑定任务栏点击事件
		// $('.task-window li').live('click',function(){
		//     Core.taskwindow($(this));
		// }).live('contextmenu',function(){
		//     //展示自定义右键菜单
		//     Core.taskwindowrightmenu($(this));
		//     //屏蔽浏览器自带右键菜单
		//     return false;
		// });
		$('.task-window').delegate('li','click',function(){
			Core.taskwindow($(this));
		}).delegate('li','contextmenu',function(){
			//展示自定义右键菜单
			Core.taskwindowrightmenu($(this));
			//屏蔽浏览器自带右键菜单
			return false;
		});
		//绑定窗口点击事件
		// $('.window-container').live('click',function(){
		//     Core.container($(this));
		// });
		$(document).delegate('.window-container','click',function(){
			Core.container($(this));
		});
		//系统设置处理
		// $('.task-panel li').bind('click',function(){
		//     //展示自定义右键菜单
		//     Core.taskwindowsystemmenu($(this));
		//     //屏蔽浏览器自带右键菜单
		//     return false;
		// });
	};

	//创建窗体
	Core.create = function(obj,opt){
		//ZENG.msgbox.show(typeof(obj), 1, 2000);
		if(typeof(obj)==='string'){
			var options = {
				num		:Date.parse(new Date()),
				imgsrc	:opt.imgsrc||"res/images/news.png",
				title	:opt.title,
				url		:opt.url,
				width	:opt.width =='100%'?$(window).width():opt.width,
				height	:opt.height =='100%'?Core.config.windowMaxHeight:opt.height,
				resize	:opt.resize,
				param   :opt.param
			};
		}else{
			var sc = obj.attr('shortcut');
			var options = {
				num		:shortcut[sc][0],
				title	:shortcut[sc][1],
				imgsrc	:shortcut[sc][2],
				url		:shortcut[sc][3],
				width	:shortcut[sc][4]=='100%'?$(window).width():shortcut[sc][4],
				height	:shortcut[sc][5]=='100%'?Core.config.windowMaxHeight:shortcut[sc][5],
				resize	:true
			};
		}
		if(options.height > Core.config.windowMaxHeight)
			options.height = Core.config.windowMaxHeight;

		var window_warp = 'window_'+options.num+'_warp';
		var window_inner = 'window_'+options.num+'_inner';
		//判断窗口是否已打开
		var iswindowopen = 0;
		$('.task-window li').each(function(){
			if($(this).attr('window')==options.num){
				iswindowopen = 1;
				//改变任务栏样式
				$('.task-window li b').removeClass('focus');
				$(this).children('b').addClass('focus');
				//改变窗口样式
				$('.window-container').removeClass('window-current');
				$('#'+window_warp).addClass('window-current').css({
					'z-index':Core.config.createIndexid
				}).show();
				//改变窗口遮罩层样式
				// $('.window-frame').show();
				// $('#'+window_inner+' .window-frame').hide();
				Core.config.createIndexid += 1;
			}
		});
		if(iswindowopen == 0){
			//增加并显示背景遮罩层
			_cache.MoveLayOut = GetLayOutBox();
			_cache.MoveLayOut.show();
			// $('.window-frame').children('div').show();
			$('.task-window li b').removeClass('focus');
			$('.window-container').removeClass('window-current');
			//任务栏，窗口等数据
			_cache.taskTemp = {
				"num":options.num,
				"title":options.title,
				"imgsrc":options.imgsrc
			};
			var top = ($(window).height()-options.height-30)/2 <= 0 ? 0 : ($(window).height()-options.height-30)/2;
			var left = ($(window).width()-options.width)/2 <= 0 ? 0 : ($(window).width()-options.width)/2;
			_cache.windowTemp = {
				"width":options.width,
				"height":options.height,
				"top":top,
				"left":left,
				"emptyW":$(window).width()-options.width,
				"emptyH":$(window).height()-options.height,
				"zIndex":Core.config.createIndexid,
				"num":options.num,
				"title":options.title,
				"imgsrc":options.imgsrc,
				"url":options.url
			};
			_cache.resizeTemp = {
				"t":"left:0;top:-3px;width:100%;height:5px;z-index:1;cursor:n-resize",
				"r":"right:-3px;top:0;width:5px;height:100%;z-index:1;cursor:e-resize",
				"b":"left:0;bottom:-3px;width:100%;height:5px;z-index:1;cursor:s-resize",
				"l":"left:-3px;top:0;width:5px;height:100%;z-index:1;cursor:w-resize",
				"rt":"right:-3px;top:-3px;width:10px;height:10px;z-index:2;cursor:ne-resize",
				"rb":"right:-3px;bottom:-3px;width:10px;height:10px;z-index:2;cursor:se-resize",
				"lt":"left:-3px;top:-3px;width:10px;height:10px;z-index:2;cursor:nw-resize",
				"lb":"left:-3px;bottom:-3px;width:10px;height:10px;z-index:2;cursor:sw-resize"
			};
			//新增任务栏
			$('.task-window').append(FormatModel(taskTemp,_cache.taskTemp));
			//新增窗口
			var win_warp = "";
			if(options.resize){
				//添加窗口缩放模板
				for(var k in _cache.resizeTemp){
					win_warp += FormatModel(resizeTemp,{
						resize_type:k,
						css:_cache.resizeTemp[k]
					});
				}
			}
			win_warp = FormatModel(FormatModel(windowTemp,{
				resize:win_warp
			}),_cache.windowTemp);
			$('#desk').append(win_warp);
			$('#'+window_warp+' .window-frame').height(options.height-70);
			if(opt && opt.width =='100%' && opt.height =='100%'){
				$('#'+window_warp).find('.Js-window-max').remove();
			}
			$('#window-frame-'+options.url).html(Core.loadTpl);
			require([options.url],function(item){
				var isWrite;
				if(obj instanceof jQuery)
					isWrite = obj.attr('isWrite');
				else
					isWrite = 0;
				item.init('windowId='+options.num+(typeof options.param != 'undefined'?'&'+options.param:''),isWrite);
			});
			Core.config.createIndexid += 1;
			//绑定窗口移动事件
			Core.bindWindowMove($('#'+window_warp));
			if(options.resize){
				//绑定窗口缩放事件
				Core.bindWindowResize($('#'+window_warp),options);
			}

			//绑定窗口功能按钮事件
			Core.handle($('#'+window_warp),options);
			//隐藏背景遮罩层
			_cache.MoveLayOut.hide();

		}
		return $('#'+window_warp);
	};

	//点击任务栏
	Core.taskwindow = function(obj){
		var window_warp = 'window_'+obj.attr('window')+'_warp';
		var window_inner = 'window_'+obj.attr('window')+'_inner';
		if(obj.children('b').hasClass('focus')){
			obj.children('b').removeClass('focus');
			$('#'+window_warp).hide();
		}else{
			//改变任务栏样式
			$('.task-window li b').removeClass('focus');
			obj.children('b').addClass('focus');
			//改变窗口样式
			$('.window-container').removeClass('window-current');
			$('#'+window_warp).addClass('window-current').css({
				'z-index':Core.config.createIndexid
			}).show();
			//改变窗口遮罩层样式
			// $('.window-frame').show();
			// $('#'+window_inner+' .window-frame').children('div');
			Core.config.createIndexid += 1;
		}
	};

	//任务栏右键菜单
	Core.taskwindowrightmenu = function(obj){
		_cache.TaskRight = GetTaskRight(obj);
		_cache.TaskRight.css({
			left:(obj.index()*(obj.width()+3)+2)+'px'
		}).show();
	};

	//任务栏系统设置
	Core.taskwindowsystemmenu = function(obj){
		_cache.TaskSystem = GetTaskSystem(obj);
		_cache.TaskSystem.css({
			right:'2px'
		}).show();
	};

	//点击窗口
	Core.container = function(obj){
		//改变任务栏样式
		$('.task-window li b').removeClass('focus');
		$('.task-window li[window="'+obj.attr('window')+'"] b').addClass('focus');
		//改变窗口样式
		$('.window-container').removeClass('window-current');
		obj.addClass('window-current').css({
			'z-index':Core.config.createIndexid
		});
		//改变窗口遮罩层样式
		// $('.window-frame').children('div').show();
		//obj.find('.window-frame').children('div').hide();
		Core.config.createIndexid += 1;
	};

	//最小化，最大化，还原，双击，关闭，刷新
	Core.handle = function(obj,options){
		//改变窗口样式
		$('.window-container').removeClass('window-current');
		obj.addClass('window-current').css({
			'z-index':Core.config.createIndexid
		});
		Core.config.createIndexid += 1;

		//最小化
		obj.find(".Js-window-min").bind("click",function(e){
			//阻止冒泡
			e.stopPropagation();
			obj.hide();
			//改变任务栏样式
			$('.task-window li[window="'+obj.attr('window')+'"] b').removeClass('focus');
		});
		//最大化
		obj.find(".Js-window-max").bind("click",function(e){
			obj.css({
				width:"100%",
				height:$(window).height()-30,
				top:0,
				left:0
			});
			$(this).hide().next(".Js-window-restore").show();
			ie6iframeheight();
			require([options.url],function(item){
				$('.window-frame',obj).height(obj.height()-50);
				item.max && item.max($(window).width(),obj.height()-50);
			});
			// ZENG.msgbox.show("按F11体验浏览器全屏模式！", 4, 2000);
		});
		//还原
		obj.find(".Js-window-restore").bind("click",function(e){
			obj.css({
				width:obj.data("info").width+"px",
				height:obj.data("info").height+"px",
				left:obj.data("info").left+"px",
				top:obj.data("info").top+"px"
			});
			$(this).hide().prev(".Js-window-max").show();
			require([options.url],function(item){
				item.restore && item.restore(obj.data("info").width,(obj.data("info").height-30));
			});
			ie6iframeheight();
		});
		//双击
		obj.find(".title-bar").bind("dblclick",function(e){
			//判断当前窗口是否已经是最大化
			if($(this).find(".Js-window-max").is(":visible")){
				$(this).find(".Js-window-max").click();
			}else{
				$(this).find(".Js-window-restore").click();
			}
		});
		//关闭
		obj.find(".Js-window-close").bind("click",function(e){
			require([options.url],function(item){
				if(item.destroy){
					if(item.destroy()){
						$('.task-window li[window="'+obj.attr('window')+'"]').remove();
						obj.remove();
					}
				}else {
					$('.task-window li[window="'+obj.attr('window')+'"]').remove();
					obj.remove();
				}
			});
		});
		//刷新
		obj.find("#refresh").bind("click",function(e){
			$("#frame"+obj.attr('window')).attr("src",$("#frame"+obj.attr('window')).attr("src"));
		});
	};

	Core.close = function(id){
		$('.task-window li[window="'+id+'"]').remove();
		$('#window_'+id+'_warp').remove();
	};

	//显示桌面
	Core.showDesktop = function(){
		$(".task-window li b").removeClass("focus");
		$("#desk ul").nextAll("div").hide();
	};

	//绑定窗口移动事件
	Core.bindWindowMove = function(obj){
		obj.data("info",{
			width:obj.width(),
			height:obj.height(),
			left:obj.offset().left,
			top:obj.offset().top,
			emptyW:$(window).width()-obj.width(),
			emptyH:$(window).height()-obj.height()
		});
		obj.find(".title-bar").bind("mousedown",function(e){

			//改变窗口为选中样式
			$('.window-container').removeClass('window-current');
			obj.addClass('window-current').css({
				'z-index':Core.config.createIndexid
			});
			Core.config.createIndexid += 1;
			x = e.screenX;	//鼠标位于屏幕的left
			y = e.screenY;	//鼠标位于屏幕的top
			sT = obj.offset().top;
			sL = obj.offset().left;
			//增加背景遮罩层
			_cache.MoveLayOut = GetLayOutBox();
			var lay = $(window);
			//绑定鼠标移动事件
			lay.unbind("mousemove").bind("mousemove",function(e){

				_cache.MoveLayOut.show();
				//强制把右上角还原按钮隐藏，最大化按钮显示
				obj.find(".Js-window-restore").hide().prev(".Js-window-max").show();
				eX = e.screenX;	//鼠标位于屏幕的left
				eY = e.screenY;	//鼠标位于屏幕的top
				lessX = eX - x;	//距初始位置的偏移量
				lessY = eY - y;	//距初始位置的偏移量
				_l = sL + lessX;
				_t = sT + lessY;
				_w = obj.data("info").width;
				_h = obj.data("info").height;
				/*
				 //鼠标贴屏幕左侧20px内
				 if(e.clientX <= 20){
				 _w = (lay.width()/2)+"px";
				 _h = "100%";
				 _l = 0;
				 _t = 0;
				 }
				 //鼠标贴屏幕右侧20px内
				 if(e.clientX >= (lay.width()-21)){
				 _w = (lay.width()/2)+"px";
				 _h = "100%";
				 _l = (lay.width()/2)+"px";
				 _t = 0;
				 }*/
				//窗口贴屏幕顶部10px内
				if(_t <= 10){
					_t = 0;
				}
				//窗口贴屏幕左边10px内
				if(_l <= 10){
					_l = 0;
				}
				//窗口贴屏幕右边10px内
				if(_l >= lay.width()-_w-10){
					_l = lay.width()-_w;
				}
				//窗口贴屏幕下边10px内 //30px 下方还有task-bar任务栏
				if(_t >= lay.height()-_h-30-10){
					_t = lay.height()-_h-30;
				}
				/*
				 ZENG.msgbox.show(lay.height()+" "+_win_h, 1, 2000);
				 //窗口贴屏幕底部60px内
				 if(_t >= (lay.height()-60)){
				 _t = (lay.height()-60)+"px";
				 if(e.clientX <= 20){
				 _w = (lay.width()/2)+"px";
				 _h = "100%";
				 _l = 0;
				 _t = 0;
				 }
				 }*/
				obj.css({
					width:_w,
					height:_h,
					left:_l,
					top:_t
				});
				obj.data("info",{
					width:obj.data("info").width,
					height:obj.data("info").height,
					left:obj.offset().left,
					top:obj.offset().top,
					emptyW:$(window).width()-obj.data("info").width,
					emptyH:$(window).height()-obj.data("info").height
				});
				ie6iframeheight();
			});
			//绑定鼠标抬起事件
			lay.unbind("mouseup").bind("mouseup",function(){
				_cache.MoveLayOut.hide();
				$(this).unbind("mousemove");
			});
		});
	};

	//绑定窗口缩放事件
	Core.bindWindowResize = function(obj,options){
		for(rs in _cache.resizeTemp){
			bindResize(rs);
		}
		function bindResize(r){
			var frame = $('.window-frame',obj);
			obj.find("div[resize='"+r+"']").bind("mousedown",function(e){
				//增加背景遮罩层
				_cache.MoveLayOut = GetLayOutBox();
				var lay = $(window);
				cy = e.clientY;
				cx = e.clientX;
				h = obj.height();
				w = obj.width();
				//增加背景遮罩层
				_cache.MoveLayOut = GetLayOutBox();
				lay.unbind("mousemove").bind("mousemove",function(e){
					_cache.MoveLayOut.show();
					_t = e.clientY;
					_l = e.clientX;
					//窗口贴屏幕顶部10px内
					if(_t <= 10){
						_t = 0;
					}
					//窗口贴屏幕底部60px内
					if(_t >= (lay.height()-60)){
						_t = (lay.height()-60);
					}

					if(_l <= 1){
						_l = 1;
					}
					if(_l >= (lay.width()-2)){
						_l = (lay.width()-2);
					}
					// $('.window-frame').children('div').hide();
					// obj.find('.window-frame').children('div').show();
					switch(r){
						case "t":
							if(h+cy-_t > Core.config.windowMinHeight){
								obj.css({
									height:(h+cy-_t)+"px",
									top:_t+"px"
								});
							}
							break;
						case "r":
							if(w-cx+_l > Core.config.windowMinWidth){
								obj.css({
									width:(w-cx+_l)+"px"
								});
							}
							break;
						case "b":
							if(h-cy+_t > Core.config.windowMinHeight){
								obj.css({
									height:(h-cy+_t)+"px"
								});
							}
							break;
						case "l":
							if(w+cx-_l > Core.config.windowMinWidth){
								obj.css({
									width:(w+cx-_l)+"px",
									left:_l+"px"
								});
							}
							break;
						case "rt":
							if(h+cy-_t > Core.config.windowMinHeight){
								obj.css({
									height:(h+cy-_t)+"px",
									top:_t+"px"
								});
							}
							if(w-cx+_l > Core.config.windowMinWidth){
								obj.css({
									width:(w-cx+_l)+"px"
								});
							}
							break;
						case "rb":
							if(w-cx+_l > Core.config.windowMinWidth){
								obj.css({
									width:(w-cx+_l)+"px"
								});
							}
							if(h-cy+_t > Core.config.windowMinHeight){
								obj.css({
									height:(h-cy+_t)+"px"
								});
							}
							break;
						case "lt":
							if(w+cx-_l > Core.config.windowMinWidth){
								obj.css({
									width:(w+cx-_l)+"px",
									left:_l+"px"
								});
							}
							if(h+cy-_t > Core.config.windowMinHeight){
								obj.css({
									height:(h+cy-_t)+"px",
									top:_t+"px"
								});
							}
							break;
						case "lb":
							if(w+cx-_l > Core.config.windowMinWidth){
								obj.css({
									width:(w+cx-_l)+"px",
									left:_l+"px"
								});
							}
							if(h-cy+_t > Core.config.windowMinHeight){
								obj.css({
									height:(h-cy+_t)+"px"
								});
							}
							break;
					}
					frame.height(obj.height()-60);

					ie6iframeheight();
					//更新窗口宽高缓存
					obj.data("info",{
						width:obj.width(),
						height:obj.height(),
						left:obj.offset().left,
						top:obj.offset().top,
						emptyW:$(window).width()-obj.width(),
						emptyH:$(window).height()-obj.height()
					});

					require([options.url],function(item){
						item.resize && item.resize(obj.width(),obj.height()-50);
					});
				});
				//绑定鼠标抬起事件
				lay.unbind("mouseup").bind("mouseup",function(){
					_cache.MoveLayOut.hide();
					$(this).unbind("mousemove");
				});
			});
		}
	};

	//透明遮罩层
	var GetLayOutBox = function(){
		if(!_cache.LayOutBox){
			_cache.LayOutBox = $('<div style="z-index:99999;display:none;cursor:default;background:none;height:100%;left:0;position:absolute;top:0;width:100%;filter:alpha(opacity=0);-moz-opacity:0;opacity:0"><div style="height:100%;width:100%"></div></div>');
			$(document.body).append(_cache.LayOutBox);
		}
		return _cache.LayOutBox;
	};
	//任务栏右键提示
	var GetTaskRight = function(obj){
		if(!_cache.TaskRight){
			_cache.TaskRight = $('<div class="popup-menu task-menu" style="z-index:99999;bottom:30px;display:none"><ul><li><a menu="close" title="关闭" href="javascript:;">关闭</a></li></ul></div>');
			$(document.body).append(_cache.TaskRight);
			$('.task-menu').bind('contextmenu',function(){
				return false;
			});
		}
		//绑定关闭事件
		$('.task-menu a[menu="close"]').unbind("click").bind("click",function(){
			$('#window_'+obj.attr('window')+'_inner .title-handle .ha-close').click();
			$('.task-menu').hide();
		});
		return _cache.TaskRight;
	};
	//任务栏右键提示
	var GetTaskSystem = function(obj){
		if(!_cache.TaskSystem){
			_cache.TaskSystem = $('<div class="popup-menu task-menu" style="z-index:99999;bottom:30px;display:none"><ul><li><a menu="close" href="javascript:;">用户登录</a></li><li><a menu="close" href="javascript:;">用户登录</a></li></ul></div>');
			$(document.body).append(_cache.TaskSystem);
			$('.task-menu').bind('contextmenu',function(){
				return false;
			});
		}
		//绑定关闭事件
		$('.task-menu a[menu="close"]').unbind("click").bind("click",function(){
			$('#window_'+obj.attr('window')+'_inner .title-handle .ha-close').click();
			$('.task-menu').hide();
		});
		return _cache.TaskSystem;
	};
	//模板格式化（正则替换）
	var FormatModel = function(str,model){
		for(var k in model){
			var re = new RegExp("{"+k+"}","g");
			str = str.replace(re,model[k]);
		}
		return str;
	};
	//IE6实时更新iframe高度
	var ie6iframeheight = function(){
		// if($.browser.msie && $.browser.version==="6.0"){
		//     $('.window-frame').css("height",($('.window-frame').parent().height()-59)+"px");
		// }
	}

</script>
</body>
</html>